package cn.wolfcode.wolf2w.common.redis.util;

import lombok.Getter;

/**
 * @author 浪兎兎
 * @since 2025-05-29-14:21
 */
@Getter
public enum RedisKeys {
    CODE("code", 300),
    STRATEGY_STATUS_HASH("status_hash", -1),
    QUESTION_STATUS_HASH("qa_status_hash", -1),
    QUESTION_ZAN("qa_zan", -1),
    QUESTION_FAVOR("qa_favor", -1),
    ANSWER_STATUS_HASH("aa_status_hash", -1),
    STRATEGY_FAVOR("strategy_favor", -1),
    STRATEGY_THUMBSUP("strategy_thumbsup", -1),
    ANIT_REFLUSH("anit_reflush", 60),
    MQ_MESSAGE("mq_message", 60),
    ANSWER_FAVOR("aa_favor", -1),
    ANSWER_ZAN("aa_zan", -1);
    /** 验证码前缀 */
    private String prefix;
    /** 有效期 */
    private long ttl;

    RedisKeys(String prefix, int ttl) {
        this.prefix = prefix;
        this.ttl = ttl;
    }

    /**
     * 拼接 key
     * @param values 拼接的字符串数组
     */
    public String join(String... values) {
        StringBuffer sb = new StringBuffer(prefix);
        for (String value : values) {
            sb.append(":").append(value);
        }
        return sb.toString();
    }
}
